<? include("conn.php");
session_start();
error_reporting(0);
$err="";
if(isset($HTTP_SESSION_VARS['username']))
    unset($HTTP_SESSION_VARS['username']);
if(isset($HTTP_SESSION_VARS['active']))
    unset($HTTP_SESSION_VARS['active']);
 
// if(isset($HTTP_SESSION_VARS['usergroup']))
    // unset($HTTP_SESSION_VARS['usergroup']);

if(isset($_REQUEST['submit']) && $_REQUEST['submit']=="Login")
{	
	$name = $_REQUEST['username'];
	$pass = $_REQUEST['password'];
    //$usergroup = $_REQUEST['usergroup'];
    $qrychk = "SELECT * FROM usermast WHERE user_id='".$name."' and user_pass='".md5($pass)."'";    
  //$qrychk = "select * from usermast where user_id='".$name."' and user_pass='".$pass."'";
	$rschk =mysql_query($qrychk) or die(mysql_error());
	if($row=mysql_fetch_assoc($rschk))
	{
		$_SESSION['username']=$row['user_id'];
		$_SESSION['usertype']=$row['usertype'];
		
		header("Location:verify_login.php");
		exit();
        // $_SESSION['usergroup']=$row['usergroup'];
		// $_SESSION['active']=time();
        // if ($_SESSION['usergroup']=='OPSUSER')
        // {
         // header("Location:transaction.php");
         // exit();
        // }
       // else
        // {
         // header("Location:griddata.php");
         // exit();
        // }
    }
  else
	{
		$err = "Invalid username or password";
	}
}
?>
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <meta name="keywords" content="html5, css3, form, switch, animation, :target, pseudo-class" />
        <meta name="author" content="Codrops" />
        <link rel="shortcut icon" href="../favicon.ico"> 
      	<link rel="stylesheet" type="text/css" href="css/style.css" />
		<link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
    </head>
  <body>
        <div class="container">
            <header>
            </header>
            <section>	
                <div id="container_demo" >
                    <a class="hiddenanchor" id="toregister"></a>
                    <a class="hiddenanchor" id="tologin"></a>
                    <div id="wrapper">
                        <div id="login" class="animate form">
                            <form  action="index.php" method="post"> 
								<p style="font-size:12px; color:#FF0000; text-align:center;"><?=$err?></p>
                                <h1>Log in</h1> 
                                <p> 
                                    <label for="username" class= "uname" data-icon="u" > Your username </label>
                                    <input type="text" name="username" required="required" />
                                </p>
                                <p> 
                                    <label for="password" class="youpasswd" data-icon="p"> Your password </label>
                                    <input id="password" name="password" required="required" type="password" /> 
                                </p>
                                <p class="login button"> 
									<input type="submit" id="submit" class="submit" name="submit" value="Login">
								</p>
                            </form>
                        </div>
                    </div>
                </div>  
            </section>
        </div>
    </body>
</html>